package Template;

import java.util.Scanner;

/**
 * 整数二分算法
 */
public class lbsAndRbs {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int q = scanner.nextInt();
        int[] arr = new int[n];
        for (int i = 0; i < n; i++) {
            arr[i] = scanner.nextInt();
        }
        for (int i = 0; i < q; i++) {
            int k = scanner.nextInt();
            int[] ints = binarySearch(arr, k);
            System.out.println(ints[0]+" "+ints[1]);
        }
    }

    private static int[] binarySearch(int[] arr, int k) {
        int[] res = new int[2];
        int n = arr.length;
        int left = 0;
        int right = n - 1;
        while (left < right) {
            int mid = left + right >> 1;
            if (arr[mid] >= k) {
                right = mid;
            } else {
                left = mid + 1;
            }
        }
        if (arr[left] != k) {
            return new int[]{-1, -1};
        }
        left = 0;
        right =n-1;
        while (left<right){
            int mid = left+right>>1;
            if (arr[mid]<=k){
                left = mid;
            }else {
                right = mid-1;
            }
        }
        res[1] = arr[left];
        return res;
    }
}
